rustfix 0.7.0

Automatically apply the suggestions made by rustc
Documentation

Library for applying diagnostic suggestions to source code.

This is a low-level library. You pass it the JSON output from rustc, and you can then use it to apply suggestions to in-memory strings. This library doesn't execute commands, or read or write from the filesystem.

If you are looking for the cargo fix implementation, the core of it is located in cargo::ops::fix.

The general outline of how to use this library is:

  1. Call rustc and collect the JSON data.
  2. Pass the json data to [get_suggestions_from_json].
  3. Create a [CodeFix] with the source of a file to modify.
  4. Call [CodeFix::apply] to apply a change.
  5. Call [CodeFix::finish] to get the result and write it back to disk.